// myDefinePlugin.ts
import  { EnvironmentPlugin } from '@rspack/core';
import type { RsbuildPlugin } from '@rsbuild/core';

if(!process.env.PUBLIC_URL){
  process.env.PUBLIC_URL =''
}

if(!process.env.DEPLOY_ENV){
  process.env.DEPLOY_ENV =''
}
if(!process.env.baseApi){
  process.env.baseApi =''
}

export const myEnvironmentPlugin = (): RsbuildPlugin => ({
  name: 'my-environment-plugin',
  setup(api) {
    api.modifyRspackConfig((config) => {
      config.plugins = config.plugins || [];
      config.plugins.push(new EnvironmentPlugin(['NODE_ENV', 'PUBLIC_URL','DEPLOY_ENV','baseApi']));
    });
  },
});